<?php
/**
*  商品分类服务
*/
class ElemeCategorySvc extends ElemeCommon
{	
    /** 添加商品分类
     * @param $shopId 店铺Id
     * @param $name 商品分类名称
     * @param $description 商品分类描述
     */
    public function createCategory($shopId = '',$name = '', $description = '')
    {
        $data = array();
        $data['shopId'] = $shopId;        
        $data['name'] = $name;        
        $data['description'] = $description;        

        return $data;
    }

    /** 
     * 发送添加商品分类
     */
    public function sendCreateCategory($data = array())
    {
        $action = 'eleme.product.category.createCategory';
        $postData = $this->getPostData($action, $data);

        $this->DLOG("create_category : " . json_encode($postData), "run", "channel_eleme");

        $res = $this->doPost($this->api_request_url, $postData);

        $this->DLOG("create_category_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_eleme");

        return $res;
    }

    /** 修改商品分类
     * @param $categoryId 分类Id
     * @param $name 商品分类名称
     * @param $description 商品分类描述
     */
    public function updateCategory($categoryId = '',$name = '', $description = '')
    {
        $data = array();
        $data['categoryId'] = $categoryId;        
        $data['name'] = $name;        
        $data['description'] = $description;        

        return $data;
    }

    /** 
     * 发送修改商品分类
     */
    public function sendUpdateCategory($data = array())
    {
        $action = 'eleme.product.category.updateCategory';
        $postData = $this->getPostData($action, $data);

        $this->DLOG("update_category : " . json_encode($postData), "run", "channel_eleme");

        $res = $this->doPost($this->api_request_url, $postData);

        $this->DLOG("update_category_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_eleme");

        return $res;
    }

    /** 查询店铺所有商品分类
     * @param $shopId 店铺Id
     */
    public function getShopCategories($shopId = '')
    {
        $data = array();
        $data['shopId'] = $shopId;        

        return $data;
    }

    /** 
     * 发送查询店铺所有商品分类
     */
    public function sendGetShopCategories($data = array())
    {
        $action = 'eleme.product.category.getShopCategories';
        $postData = $this->getPostData($action, $data);

        $this->DLOG("get_shop_categories : " . json_encode($postData), "run", "channel_eleme");

        $res = $this->doPost($this->api_request_url, $postData);

        $this->DLOG("get_shop_categories_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_eleme");

        return $res;
    }

    /** 删除分类
     * @param $categoryId 商品分类Id
     */
    public function removeCategory($categoryId = '')
    {
        $data = array();
        $data['categoryId'] = $categoryId;        

        return $data;
    }

    /** 
     * 发送删除分类
     */
    public function sendRemoveCategory ($data = array())
    {
        $action = 'eleme.product.category.removeCategory';
        $postData = $this->getPostData($action, $data);

        $this->DLOG("remove_category : " . json_encode($postData), "run", "channel_eleme");

        $res = $this->doPost($this->api_request_url, $postData);

        $this->DLOG("remove_category_res : " . json_encode($res, JSON_UNESCAPED_UNICODE), "run", "channel_eleme");

        return $res;
    }                        
}